<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>外边距合并-嵌套块级元素垂直外边距塌陷</title>
    <style>
        /* 解决垂直外边距塌陷方案：
        1.为父元素定义上边框 
        2.为父元素定义上内边距
        3.为父元素添加overflow:hidden;*/
        .father {
            width: 500px;
            height: 500px;
            background-color: pink;
            /* border: 1px solid transparent;为父元素定义上边框 */
            /* padding: 1px;为父元素定义上内边距 */
            overflow: hidden;
            /*为父元素添加overflow:hidden,不会撑大盒子 */

        }

        .son {
            width: 200px;
            height: 200px;
            background-color: skyblue;
            margin-top: 100px;
        }
    </style>
</head>

<body>
    <div class="father">
        <div class="son"></div>
    </div>
</body>

</html>